/*
 * Sprite.h
 *
 *  Created on: Feb 5, 2010
 *      Author: dcrown
 */

#ifndef SPRITE_H_
#define SPRITE_H_

#include <d3d9.h>
#include <d3dx9.h>
#include <string>

#include "Texture.h"

using std::string;

class Sprite
{
public:
	Sprite() {Clear();}
	virtual ~Sprite() {}

	void Clear();
	bool Create(string id, Texture* texture = NULL);
	void Destroy();

	void Draw();
	void Update();
	void SetTextureRect(RECT* r);
	void SetTexture(Texture* t);

	void ResetTransform();
	void Scale(float x, float y);//scale based on current size of the sprite
	void ScaleOriginal(float x, float y);//scale based on original size of the sprite
	void Translate(int x, int y);//translate based on current position of the sprite
	void TranslateOriginal(int x, int y);//translate based on original position of the sprite
	void Rotate(float rads);//translate based on current position of the sprite
	void RotateOriginal(float rads, int x, int y);//translate based on original position of the sprite

private:
	LPD3DXSPRITE sprite;
	Texture* texture;
	RECT* r;
	string id;

	//transformations
	D3DXVECTOR2 scale;
	D3DXVECTOR2 translate;
	D3DXVECTOR2 rotCenter;
	float rotate;
};

#endif /* SPRITE_H_ */
